package com.app.controller;


import com.app.common.Result;
import com.app.model.AwardInfoModel;
import com.app.service.AwardInfoService;
import com.app.utils.CommonHelp;
import com.app.vo.AwardInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *  获奖信息
 * @author 16693103420
 * @since 2024-01-25
 */
@RestController
@RequestMapping("/awardInfo")
public class AwardInfoController {
    @Autowired
    private AwardInfoService awardInfoService;

    //查询获奖信息列表
    @GetMapping("/getAwardInfoList")
    public Result getAwardInfoList(@RequestParam(defaultValue = "0") Integer page,
                                   @RequestParam(defaultValue = "10") Integer limit,Integer activityId) {
        AwardInfoVo awardInfoVo = awardInfoService.getAwardInfoList(page, limit,activityId);
        return Result.success(awardInfoVo);
    }

    //根据id查询
    @GetMapping("/getAwardInfoById")
    public Result getAwardInfoById(Integer id) {
        AwardInfoModel awardInfo = awardInfoService.getById(id);
        return Result.success(awardInfo);
    }

//    //新增和修改
//    @PostMapping("/addAndUpdateAwardInfo")
//    public Result addAndUpdateAwardInfo(@RequestBody AwardInfoModel awardInfoModel) {
//        AwardInfoModel AwardInfo = awardInfoService.getById(awardInfoModel.getId());
//        if (AwardInfo != null) {
//            awardInfoModel.setUpdateTime(CommonHelp.getNowTimestamp());
//            awardInfoService.updateById(awardInfoModel);
//            return Result.success("修改成功");
//        } else {
//            awardInfoModel.setCreateTime(CommonHelp.getNowTimestamp());
//            awardInfoService.save(awardInfoModel);
//            return Result.success("添加成功");
//        }
//    }
//    //根据id删除
//    @GetMapping("/delAwardInfo")
//    public Result delAwardInfo(Integer id) {
//        awardInfoService.removeById(id);
//        return Result.success("删除成功");
//    }

}

